package com.nullpointer.xchatfinal.object;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class GroupChat {
	private String groupJID;
	private String name;
	private int numMember;
	private String avatarURL;
	private String dialogID;
	private boolean isPublicGroup = true;

	public boolean isPublicGroup() {
		return isPublicGroup;
	}

	public void setPublicGroup(boolean isPublicGroup) {
		this.isPublicGroup = isPublicGroup;
	}

	public String getDialogID() {
		return dialogID;
	}

	public void setDialogID(String dialogID) {
		this.dialogID = dialogID;
	}

	public String getGroupJID() {
		return groupJID;
	}

	public void setGroupJID(String groupJID) {
		this.groupJID = groupJID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getNumMember() {
		return numMember;
	}

	public void setNumMember(int numMember) {
		this.numMember = numMember;
	}

	public String getAvatarURL() {
		return avatarURL;
	}

	public void setAvatarURL(String avatarURL) {
		this.avatarURL = avatarURL;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static GroupChat fromJsonToGroupChat(String json) {
		return new JSONDeserializer<GroupChat>().use(null, GroupChat.class)
				.deserialize(json);
	}

	public static String toJsonArray(Collection<GroupChat> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

	public static Collection<GroupChat> fromJsonArrayToGroupChats(String json) {
		return new JSONDeserializer<List<GroupChat>>()
				.use(null, ArrayList.class).use("values", GroupChat.class)
				.deserialize(json);
	}

}
